home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / adasmall / read.me < prev    next >
Text File  |  1996-01-30  |  12KB  |  258 lines

  1. S M A L L A d a   1 9 9 1
  2. IBM PC-family version
  3.  
  4. Department of Electrical Engineering and Computer Science
  5. The George Washington University
  6. Washington, DC 20052 USA
  7.  
  8. This is a compiler/interpreter for a part of the Ada language, namely
  9. the "Pascal subset" plus the Ada tasking support. It is not intended
  10. ever to be a full Ada compiler, rather a vehicle for teaching, learning,
  11. and experimenting with concurrent programming. The compiler is quite
  12. fast, producing P-code which is then interpreted by the interpreter.
  13.  
  14. The system will run on an IBM PC (or compatible) with the following
  15. minimum configuration: 640K of memory; one disk drive. A hard disk will
  16. greatly improve the speed. The entire system runs in RAM with no disk
  17. accesses, so expect capacity to be limited. 250 statements or so can
  18. be safely accommodated.
  19.  
  20. The current version is not particularly robust, rather it is a preliminary
  21. step toward effective window-oriented monitoring of task execution.
  22.  
  23. This package may be copied and used for educational purposes but not for
  24. profit; please let us know how you like the idea of this package and what
  25. you are doing with it. Please do NOT post this package on a bulletin board
  26. or newsgroup. We'd like to have reasonable knowledge of who is using it
  27. and WILL object if it turns up on a public server somewhere!
  28.  
  29. project supervised by
  30. Prof. Michael B. Feldman
  31. 202-994-5253
  32. mfeldman@seas.gwu.edu
  33.  
  34. authors:
  35. 1986 Charles Schoening             DOS version of CoPascal
  36. 1987 Frederick C. Hathorn          conversion of CoPascal to Ada
  37. 1988 Stuart Cramer and Jay Kurtz   refinement of tasking model
  38. 1989 Arthur V. Lopes               window-oriented monitoring for IBM-PC
  39. 1990 Manuel A. Perez               Macintosh version
  40. 1990 Arthur V. Lopes               integrated environment for IBM-PC
  41. 1991 Amr El-Kadi                   user-selectable task scheduling
  42.  
  43. HOW TO RUN THE PC PROGRAM
  44. =========================
  45.  
  46. To run SMALLAda PC you will need the following files:
  47.  
  48. SMALLADA.EXE    -- Small Ada integrated environment
  49. SMADA-IN.AVL    -- Small Ada interpreter pseudo code; it can be tunned
  50.                 -- to suit any level of interpreter monitoring
  51.  
  52. Type SMALLADA RACE <enter>. You will be placed in the editor mode. To compile
  53. and run the race program follow these steps: press F10. A menu will appear
  54. on the top of your screen. Press C, for compiler. Then a sub menu will be
  55. displayed. Press E (or <enter>. This will start the compilation process.
  56. If the program is correctly compiled then it will run thereafter. If an
  57. error is found an error message will be issued and after pressing any key
  58. the editor will be activated. The cursor will be at the line where the
  59. error was found.
  60.  
  61. The program will run much faster if you disable the window-oriented
  62. execution monitoring by pressing <INS>, which toggles monitoring on and
  63. off. If monitoring is enabled, pressing <DEL> toggles step-by-step
  64. execution on and off. With stepped execution on, pressing the space
  65. bar moves through each source line.
  66.  
  67. You can create and compile your own Ada programs, but we make no promises
  68. about which parts of the language will be handled correctly. We assure you
  69. that there is no support for packages, generics, exceptions, access types
  70. and dynamic data structures. Some of this may change in future versions,
  71. but we make no commitment to support full Ada. And don't be surprised if
  72. the compiler hangs here and there: error repair is in a rather primitive state.
  73. If the compiler actually finds your errors, it will display the messsages in
  74. a window.
  75.  
  76.  
  77. THE SmallAda IBM-PC RUNTIME ENVIRONMENT
  78. =======================================
  79.  
  80. The runtime monitoring of tasking is really the whole point of this
  81. project.
  82.  
  83. Each task is given a window. If there are more than five tasks some tasks
  84. will share a physical window.
  85.  
  86. To obtain help on the runtime environment press F1 while a program is running.
  87. In summary, you can control the overall execution speed of the interpreter
  88. (to "slow down the action"), and exert some influence on the open windows.
  89. There is no magic in all this runtime monitoring: it all takes machine cycles.
  90. If you wish your program to run faster, remove all the monitoring windows
  91. (by pressing INS while they are open). You can also step through execution,
  92. source line by source line, by pressing INS while windows are open. Then
  93. pressing the space bar steps through one source line.
  94.  
  95.  
  96. THE SmallAda EDITOR
  97. ===================
  98.  
  99. The editor was adapted from the Turbo Pascal Editor Toobox Version 4.0.
  100. The editor works much like the Wordstar editor. Next some of its basic
  101. options are shown.
  102.  
  103.  
  104. Function                        Keystrokes
  105.  
  106. BASIC MOVEVMENT COMMANDS:
  107.  
  108. Character left:                 left arrow or ^S (^ ==> Control)
  109. Character right                 right arrow or ^D
  110. Word left                       ^left arrow or ^A
  111. Word right                      ^right arrow or ^F
  112. Line up                         up arrow or ^E
  113. Line down                       down arrow or ^X
  114. Scroll up                       ^W
  115. Scroll down                     ^Z
  116. Page up                         PgUp or ^R
  117. Page down                       PGDn or ^C
  118. Beginning of Line               Home or ^Q S
  119. End of Line                     End or ^Q D
  120. Tab                             Tab or ^I
  121. Backward tab                    Shift tab
  122.  
  123. BASIC EDITING COMMANDS:
  124.  
  125. New line                        Enter or ^M
  126. Insert line                     ^N
  127. Delete current character        Del or ^G
  128. Delete character left           Backspace or ^H
  129. Delete word                     ^T
  130. Delete to end of line           ^Q Y
  131. Activate menus                  F10
  132. Abort command                   ^U
  133.  
  134.  
  135.  
  136. THE SmallAda TASKING MODEL
  137. ===========================
  138.  
  139. We have tried to be reasonably faithful to Ada tasking. The scheduler is
  140. designed to show some of the important issues of concurrent programming,
  141. therefore time-slicing is implemented, and the length of the slice is
  142. randomly determined. Also, at each rescheduling point the next task to
  143. be scheduled is selected randomly. This is to give a reasonable model of
  144. nondeterministic (unpredictable) behavior, and serves to highlight the
  145. need for mutual exclusion. The dining philosophers examples on the
  146. disk, taken together, show this point rather well.
  147.  
  148. Current incompletenesses in the tasking model: only named tasks (i.e. no
  149. task types), no dynamically created tasks. We also don't support nested
  150. task declarations; all tasks must be declared in MAIN's declarative section.
  151.  
  152. The "select" statement is functional including the "terminate" alternative;
  153. checking for termination is tricky in Ada and you might find that some
  154. select structures with terminate alternatives deadlock or don't work at all.
  155. In general, be gentle with the select statement; try to avoid tricky or
  156. pathological code, which will surely choke the compiler or interpreter!
  157.  
  158. You will also discover quickly that though the "delay" statement is functional,
  159. the elapsed time to expiration of the delay is considerably more than was
  160. requested in the delay statement. As it happens, this is correct Ada, as the
  161. standard says only that a task will be suspended for _at least_ the amount
  162. of time requested. This is to take account of the likelihood that contention
  163. will make it impossible for a task to take immediate control when it wakes
  164. up from a nap. Indeed, we think that the sometimes too-long delays
  165. may be due to the interference in the interpreter caused by all the references
  166. to the user interface for monitoring purposes. The relationship of the delay to 
  167. reality depends upon your PC's speed as well. We are working on this problem
  168. but do not yet see an obvious solution. So take the time given in a delay
  169. statement with a grain of salt, please.
  170.  
  171. If you have tasks in finite (counting) loops, if they complete but there are 
  172. other tasks with infinite loops that can never terminate, the system may 
  173. detect no activity and report a deadlock state. 
  174.  
  175. The current version now supports user-selected task scheduling. Pressing
  176. <alt-F10> during execution opens a window giving scheduler options.
  177.  
  178.  
  179. THE SmallAda SUPPORT PACKAGE (SMALL_SP.PKG)
  180. ===========================================
  181.  
  182. A large number of "intrinsic" library subroutines are included in a
  183. pseudo-package called SMALL_SP.PKG. It is not necessary (or proper) to
  184. compile this package; it is included in the environment. It is necessary
  185. to begin each program with a context clause
  186.  
  187. WITH SMALL_SP; USE SMALL_SP;
  188.  
  189. to give the effect of writing genuine Ada. A specification for this
  190. package is included in the distribution; it includes I/O routines,
  191. math functions, and the like. This is not really good Ada-like decomposition,
  192. and we will change it in subsequent versions of the system. Meanwhile, use
  193. the package spec as a guide to all the intrinsic routines. Note especially
  194. that the formatting parameters supplied to the I/O procedures are more
  195. Pascal-like than Ada-like. This will change later to look more like
  196. standard TEXT_IO.
  197.  
  198.  
  199. THE DEMONSTRATION PROGRAMS
  200. ==========================
  201.  
  202. We have supplied a set of what we hope will be interesting and instructive
  203. programs illustrating both the sequential aspects of the Ada subset and
  204. the tasking model.
  205.  
  206. TEST1 through TEST6 can be thought of as "validation" programs testing 
  207. specific features of the language; reading them can serve a useful purpose 
  208. in understanding our subset.
  209.  
  210. ATEST1 through ATEST4 demonstrate the differences in program behavior
  211. under different scheduling policies. Each program contains a block
  212. comment explaining its purpose in this demonstration.
  213.  
  214. SHELLSORT is what its name implies: a standard implementation of Shell sort
  215. in which the state of the array is displayed on the screen as it is sorted;
  216. RACE is a tasking program which we have used with success in concurrent
  217. programming courses: three sort algorithms are activated as Ada tasks
  218. and run in parallel.
  219.  
  220. 4TASKSEM shows the use of the semaphore primitives "exported" by the SMALL_SP
  221. pseudo-package. A semaphore SCREEN is declared and used to give mutual
  222. exclusion on the terminal screen.
  223.  
  224. Attention: semaphores are NOT Ada primitives! SmallAda was originally 
  225. constructed as a modification to the CoPascal system of Ben-Ari
  226. (as described in "Principles of Concurrent Programming", Prentice Hall 1982),
  227. and the semaphore primitives are still there from the system's last
  228. incarnation. To show how to do it in "real" Ada, we include the program
  229. 4TASKMON, in which a screen monitor task is declared.
  230.  
  231. Finally, there are three versions of Dijkstra's legendary dining philosophers
  232. problem. SmallAda has a capacity limitation of around ten tasks. We are
  233. limited to four instead of the usual five philosophers, because four diners,
  234. four chopsticks, and MAIN add up to 9 tasks. EATCHAOS is very instructive:
  235. it demonstrates why it's nice to have monitors for mutual exclusion: without
  236. a monitor guarding the screen, the display becomes rather chaotic. EAT-SEM
  237. uses the SmallAda semaphore primitives; EAT-MON does the same thing but
  238. with a "genuine" Ada monitor.
  239.  
  240. FINALLY
  241. =======
  242.  
  243. In case you are curious, the system is coded in Turbo Pascal with the
  244. Turbo Toolbox libraries used for the editor and environment. 
  245.  
  246. Please let us know about bugs; tell us what you're doing with
  247. the sytem. Good luck; have fun!
  248.  
  249.  
  250. Good luck; have fun!
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.